package team.headnurse.nursemanagement.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import team.headnurse.nursemanagement.dao.NightExpectationDao;
import team.headnurse.nursemanagement.model.NightExpectation;
import team.headnurse.nursemanagement.service.NightExpectationService;

import javax.annotation.Resource;

/**
 * @author Eugene-Forest
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class NightExpectationServiceImpl implements NightExpectationService {

    @Resource
    private NightExpectationDao nightExpectationDao;

    /**
     * 插入一条夜班期望记录
     *
     * @param expectation 夜班期望
     * @return 如果成功则返回数字1
     */
    @Override
    public int insert(NightExpectation expectation) {
        return nightExpectationDao.insert(expectation);
    }

    /**
     * 通过 id 查找一条夜班期望记录
     *
     * @param staffId  员工id
     * @param priority 优先级
     * @return 如果成功则返回夜班期望对象
     */
    @Override
    public NightExpectation selectById(String staffId, int priority) {
        return nightExpectationDao.selectById(staffId, priority);
    }

    /**
     * 更新一条夜班期望记录
     *
     * @param expectation 夜班期望对象
     * @return 如果成功则返回数字1
     */
    @Override
    public int update(NightExpectation expectation) {
        return nightExpectationDao.update(expectation);
    }

    /**
     * 删除一条夜班期望记录
     *
     * @param expectation 夜班期望对象
     * @return 如果成功则返回数字1
     */
    @Override
    public int delete(NightExpectation expectation) {
        return nightExpectationDao.delete(expectation);
    }
}
